//山东通免登录接入
import request from "@/utils/request.js";

export const getQueryString = (name)=> {
  let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  let r = window.location.search.substr(1).match(reg);
  if (r != null) {
    return unescape(r[2]);
  }
  return null;
}

export const getCode = (cb) => {
  let code = getQueryString('code') || 'dingc2ebee6fdfd68866a1320dcb25e91351' //企业ID 见下图
  request.get('/sdt/getuserinfo', {
    code: code
  }).then(res => {
    uni.setStorageSync('userInfo', res.result || {});
    cb(res)
  })
}